var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (i, t) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, i) {
              e.__proto__ = i;
            }) ||
          function (e, i) {
            for (var t in i)
              Object.prototype.hasOwnProperty.call(i, t) && (e[t] = i[t]);
          })(i, t);
      };
      return function (i, t) {
        function n() {
          this.constructor = i;
        }
        if ("function" != typeof t && null !== t)
          throw new TypeError(
            "Class extends value " + String(t) + " is not a constructor or null"
          );
        e(i, t),
          (i.prototype =
            null === t
              ? Object.create(t)
              : ((n.prototype = t.prototype), new n()));
      };
    })(),
  BuyMedicalView = (function (e) {
    function i() {
      var i = e.call(this) || this;
      return (
        (i.max = 99),
        (i.min = 1),
        (i.step = 1),
        (i.num = 1),
        (i.price = 10),
        (i.treasure_type = !1),
        (i.goumaiListener = {
          caller: i,
          code: 15,
          method: function (e) {
            i.close();
          },
        }),
        (i.onLoadBuyMedicalResultFn = {
          caller: i,
          code: 1249,
          method: function (e) {
            0 == e.code
              ? (i.close(),
                ToastView.toastView(e.data),
                WebSocketService.send({ c: 1451, d: { pageNum: 0 } }))
              : ToastView.toastView(e.msg);
          },
        }),
        (i.onLoadTreasureChargeDataFn = {
          caller: i,
          code: 1203,
          method: function (e) {
            0 != e.code
              ? ToastView.toastView(e.msg)
              : 0 == e.code &&
                (ToastView.toastView(e.msg),
                WebSocketService.send({ c: 1451, d: { pageNum: 0 } })),
              i.close();
          },
        }),
        i.buyMedBtn.on(Laya.Event.CLICK, i, i.onBuyShopping),
        i.closeBtn.on(Laya.Event.CLICK, i, i.close),
        i.plusBtn.on(Laya.Event.CLICK, i, i.plusBtnClick),
        i.minusBtn.on(Laya.Event.CLICK, i, i.minusBtnClick),
        i.numSlider.on(Laya.Event.CHANGE, i, i.sliderChange),
        WebSocketService.addListener(i.onLoadBuyMedicalResultFn, !0),
        WebSocketService.addListener(i.goumaiListener),
        WebSocketService.addListener(i.onLoadTreasureChargeDataFn),
        WebSocketService.addListener({
          caller: i,
          code: 18251,
          method: i.onLoadSureBuyFuBenYaoPin,
        }),
        i
      );
    }
    return (
      __extends(i, e),
      (i.showMedical = function (e, t, n, s) {
        null == this.buyMedicalView &&
          ((this.buyMedicalView = new i()), (this.buyMedicalView.zOrder = 1e3)),
          (this.buyMedicalView.treasure_type = !1),
          this.buyMedicalView.popup(!0),
          (this.buyMedicalView.isFuBen = s),
          (this.buyMedicalView.price = t),
          (this.buyMedicalView.shopsId = n),
          (this.buyMedicalView.shopname = e),
          (this.buyMedicalView.nameLabel.text = e),
          (this.buyMedicalView.numSlider.value = this.buyMedicalView.num),
          (this.buyMedicalView.label_unit.text = "银"),
          (this.buyMedicalView.num = 1),
          this.buyMedicalView.updateMedicalData();
      }),
      (i.prototype.updateMedicalData = function () {
        (this.numSlider.value = this.num),
          (this.nameLabel.text = this.shopname),
          (this.numLabel.text = this.num + ""),
          (this.sumLabel.text = this.num * this.price + "");
      }),
      (i.prototype.onBuyShopping = function (e) {
        1 == this.treasure_type
          ? WebSocketService.send({
              c: 1203,
              d: { gid: this.thingObj.id, count: this.num },
            })
          : this.isFuBen
          ? WebSocketService.send({
              c: 18251,
              d: { goodsId: this.shopsId, count: this.num },
            })
          : WebSocketService.send({
              c: 1249,
              d: {
                goodsId: this.shopsId,
                count: this.num,
                silverType: 0,
                retType: 0,
              },
            });
      }),
      (i.prototype.plusBtnClick = function () {
        (this.num = this.num + this.step),
          this.num > this.max && (this.num = this.max),
          (this.numSlider.value = this.num),
          this.updateMedicalData();
      }),
      (i.prototype.minusBtnClick = function () {
        (this.num = this.num - this.step),
          this.num < this.min && (this.num = this.min),
          (this.numSlider.value = this.num),
          this.updateMedicalData();
      }),
      (i.prototype.sliderChange = function () {
        (this.num = this.numSlider.value), this.updateMedicalData();
      }),
      (i.showTreasure = function (e) {
        null == this.buyMedicalView &&
          ((this.buyMedicalView = new i()), (this.buyMedicalView.zOrder = 1e3)),
          this.buyMedicalView.popup(!0),
          (this.buyMedicalView.treasure_type = !0),
          (this.buyMedicalView.thingObj = e),
          (this.buyMedicalView.price = e.price),
          (this.buyMedicalView.shopsId = e.id),
          (this.buyMedicalView.shopname = e.name),
          (this.buyMedicalView.nameLabel.text = e.name),
          (this.buyMedicalView.numSlider.value = this.buyMedicalView.num),
          (this.buyMedicalView.label_unit.text = "金"),
          (this.buyMedicalView.num = 1),
          this.buyMedicalView.updateMedicalData();
      }),
      (i.prototype.onLoadSureBuyFuBenYaoPin = function (e) {
        0 == e.code && this.close(), ToastView.toastView(e.msg);
      }),
      (i.close = function () {
        this.buyMedicalView &&
          ((this.buyMedicalView = null), this.buyMedicalView.removeSelf());
      }),
      i
    );
  })(ui.HospitalController.BuyMedicinesViewUI);
